package com.spa.interfaces.admin;

import com.spa.application.command.admin.UserInfoLogOffCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.admin.UserInfoDto;
import com.spa.application.query.admin.UserInfoQuery;
import com.spa.application.service.admin.UserInfoApplicationService;
import com.spa.infrastructure.common.ResponseMessage;
import com.spa.interfaces.BaseController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("admin/userInfo")
public class AdminUserInfoController extends BaseController {

    @Resource
    private UserInfoApplicationService userInfoApplicationService;

    @PostMapping("/pageList")
    public ResponseMessage<PageResult<UserInfoDto>> list(@RequestBody UserInfoQuery userInfoQuery){
        return responseHelper.success(userInfoApplicationService.pageUserInfo(userInfoQuery));
    }

    @PostMapping("/logOffUserInfo")
    public ResponseMessage logOffUser(@RequestBody UserInfoLogOffCommand command){
        userInfoApplicationService.logOffUser(command);
        return responseHelper.success("重置用户成功",null);
    }

}
